(<any>window)._globalEvent = new cc.EventTarget();

export class GlobalEvent {

    //全局事件
    static Event = {
        //打开窗口：PanelId, Data
        openPanel : "OPEN_PANEL",

        //窗口关闭时：PanelId
        onPanelClose :"ON_PANEL_CLOSE",

        //进入场景：SceneName
        enterScene: "ENTER_SCENE",

        //返回场景
        backScene: "BACK_SCENE",

        //切换攻击模式
        swtichAttackMode:"SWITCH_ATTACK_MODE",

        //场景加载进度：CompleteCount, TotalCount, Itme
        loadingSceneProgress:"LOADING_SCENE_PROGRESS", 

        //场景加载完成：CurSceneName, PreSceneName
        loadingSceneComplete:"LOADING_SCENE_COMPLETE",

        //摇杆开始
        joyStickStart:"JOY_STICK_START",

        //摇杆方向：Dir
        joyStickDir:"JOY_STICK_DIR",

        //摇杆停止
        joyStickStop:"JOY_STICK_STOP",

        //model数据更新
        modelDataUpdate:"MODEL_DATA_UPDATE",

        //model数据修改
        modelDataChg:"MODEL_DATA_CHG",
    }

    static emit(siganl, Data?:any)
    {
        (<any>window)._globalEvent.emit(siganl, Data);
    }

    static on(siganl, func, target)
    {
        (<any>window)._globalEvent.on(siganl, function(event){
            func(event);
        }, target);
    }
}